//axios基础的封装
import axios from 'axios'
import { ElMessage } from 'element-plus'
import 'element-plus/theme-chalk/el-message.css'

import router from '@/router'


// 创建axios实例
const httpInstancd = axios.create({
  baseURL: 'http://47.94.85.91:8080/',
  timeout: 50000
})
// request拦截器，添加 Authorization 头
httpInstancd.interceptors.request.use(config => {
  const token = window.localStorage.getItem('token') // 从 localStorage 中获取 token
  if (token) {
    config.headers['Authorization'] = `Bearer ${token}` // 设置 Authorization 头
  }
  return config
}, error => {
  return Promise.reject(error)
})

export default httpInstancd